package com.red.wine.ui;

import java.net.URISyntaxException;

import com.red.wine.R;
import com.red.wine.util.IntentUtil;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class CommunityActivity extends BaseActivity {
	private Context context;
	private TextView imageView1;
	private TextView imageView2;
	private TextView imageView3;
	private TextView imageView4;
	private ImageView back;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shequ_layout);
		context = this;
		
		back = (ImageView) findViewById(R.id.shequ_info_back);
		back.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				IntentUtil.redirectToNext(context, MainActivity.class);
				finish();
			}
		});
		imageView1 = (TextView) findViewById(R.id.jianshang_zashi);
		imageView1.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				String url = "http://weibo.com/wineappreciation";
				showLoading();
				Intent intent = new Intent();        
		        intent.setAction("android.intent.action.VIEW");    
		        Uri content_url = Uri.parse(url);   
		        intent.setData(content_url);  
		        startActivity(intent);
				hideLoading();
			}
		});
		imageView2 = (TextView) findViewById(R.id.zhangyu_guanfangi);
		imageView2.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				showLoading();
				String url = "http://t.163.com/2086755241";
				showLoading();
				Intent intent = new Intent();        
		        intent.setAction("android.intent.action.VIEW");    
		        Uri content_url = Uri.parse(url);   
		        intent.setData(content_url);  
		        startActivity(intent);
				hideLoading();
			}
		});
		imageView3 = (TextView) findViewById(R.id.zhangyudianshang_guanfangi);
		imageView3.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				showLoading();
				String url = "http://qing.blog.sina.com.cn/2230236117";
				showLoading();
				Intent intent = new Intent();        
		        intent.setAction("android.intent.action.VIEW");    
		        Uri content_url = Uri.parse(url);   
		        intent.setData(content_url);  
		        startActivity(intent);
				hideLoading();
			}
		});
		imageView4 = (TextView) findViewById(R.id.zhangyutianmap_guanfangi);
		imageView4.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				showLoading();
				String url = "http://jx.tmall.com/shop/299247819.htm";
				showLoading();
				Intent intent = new Intent();        
		        intent.setAction("android.intent.action.VIEW");    
		        Uri content_url = Uri.parse(url);   
		        intent.setData(content_url);  
		        startActivity(intent);
				hideLoading();
			}
		});
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK){
			IntentUtil.redirectToNext(context, MainActivity.class);
			finish();
		}
		return super.onKeyDown(keyCode, event);
	}
}
